package com.compomics.proteocloud.db.accessor;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

public class ProteinDAO extends ProteinTableAccessor {
	
	  /**
     * Calls the super class.
     * @param params
     */
    public ProteinDAO(HashMap params){
        super(params);
    }
    
    /**
     * This constructor reads the spectrum file from a result set. The ResultSet should be positioned such that a single
     * row can be read directly (i.e., without calling the 'next()' method on the ResultSet).
     *
     * @param aRS ResultSet to read the data from.
     * @throws SQLException when reading the ResultSet failed.
     */
    public ProteinDAO(ResultSet aRS) throws SQLException {
        super(aRS);
    }

    public static ProteinDAO findFromID(long proteinID, Connection aConn) throws SQLException {
        ProteinDAO temp = null;
        PreparedStatement ps = aConn.prepareStatement(getBasicSelect() + " where proteinid = ?");
        ps.setLong(1, proteinID);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            temp = new ProteinDAO(rs);
        }
        rs.close();
        ps.close();
        return temp;
    }

}
